package com.mc.music_web.services.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mc.music_web.entity.User;
import com.mc.music_web.mapper.SingerMapper;
import com.mc.music_web.mapper.UserMapper;
import com.mc.music_web.services.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpSession;
import java.util.List;
@Service
@Transactional
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    public  User UserLogin(User user){



        return  userMapper.UserLogin(user);

    }

    public int regeriter(User user) {



        return   userMapper.regeriter(user);
    }

    public List<User> sellectUser() {
        List<User> list=userMapper.sellectUser();
        return list;
    }

    public int delterUser(Integer userId) {
        return userMapper.delterUser(userId);
    }


    public User selectByPrimaryKeyUser(Integer userId) {
        return userMapper.selectByPrimaryKeyUser(userId);
    }

    public int updateUser(User user) {
        return userMapper.updateUser(user);
    }

    public PageInfo selectUserLimit(int pageNum) {
        PageHelper.startPage(pageNum,3);
        List<User> list = userMapper.sellectUser();
        PageInfo<User> pageInfo = new PageInfo<User>(list);
        System.out.println("当前页码："+pageInfo.getPageNum());
        System.out.println("页面大小："+pageInfo.getPageSize());
        System.out.println("总记录数："+pageInfo.getTotal());
        System.out.println("是否有上一页："+pageInfo.isHasPreviousPage());
        System.out.println("是否有下一页："+pageInfo.isHasNextPage());
        System.out.println("总页面数："+pageInfo.getPages());
        return pageInfo;
    }

    public List<User> selectByChooseUser(String keyword) {
        return userMapper.selectByChooseUser(keyword);
    }
}
